import axios from 'axios'
import { CHANNEL_GET, CHANNEL_SETACTIVEID } from '../actionTypes'

export const getChannel = () => {
  const fn = async (dispatch) => {
    const res = await axios.get('http://geek.itheima.net/v1_0/channels')
    console.log('获取频道数据', res)

    dispatch({ type: CHANNEL_GET, payload: res.data.data.channels })
  }
  return fn
}

export const setActiveId = (id) => {
  return { type: CHANNEL_SETACTIVEID, payload: id }
}
